package com.zjy.health_ms.config;

import com.zjy.health_ms.interceptor.CrossInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @program: health_ms
 * @ClassName InterceptorConfig
 * @description:
 * @author: Ats
 * @create: 2025-05-12 16:18
 * @Version 1.0
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    /**
     * 向容器中添加跨域验证拦截器
     * @return
     */
    public CrossInterceptor crossInterceptor(){
        return new CrossInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 跨域拦截规则
        registry.addInterceptor(crossInterceptor()).addPathPatterns("/**");
    }
}
